﻿#Region "Copyright/License"

'  Copyright (C) 2011, 2012, 2013 Paycircuit.com, Thinking Spot, Ed Chavez
'  http://goo.gl/jty8r
' 
'  Licensed under the Apache License, Version 2.0 (the "License");
'  you may not use this file except in compliance with the License.
'  You may obtain a copy of the License at
' 
'       http://www.apache.org/licenses/LICENSE-2.0
' 
'  Unless required by applicable law or agreed to in writing, software
'  distributed under the License is distributed on an "AS IS" BASIS,
'  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'  See the License for the specific language governing permissions and
'  limitations under the License.

#End Region

Imports System.Runtime.Serialization

Namespace google.iap

#Region "Notes"
    'Order Property of DataMember is used (only) for easier unit testing with Google's demo page. There is no "required order".
    'Otherwise, the default datacontract datamember order is alphabetical making it impossible to test using Google demo page.
    'Google testing/demo page: https://sandbox.google.com/checkout/customer/gadget/inapp/demo.html

    'REF: http://self-issued.info/docs/draft-jones-json-web-token.html#anchor4
#End Region

    <DataContract()>
    Public MustInherit Class JWTClaim

        ''' <summary>
        ''' The iss (issuer) claim identifies the principal that issued the JWT. 
        ''' The processing of this claim is generally application specific. 
        ''' The iss value is case sensitive. 
        ''' This claim is OPTIONAL.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <DataMember(EmitDefaultvalue:=False, Order:=1)>
        Public Overridable Property iss As String = String.Empty

        ''' <summary>
        ''' The aud (audience) claim identifies the audience that the JWT is intended for. 
        ''' The principal intended to process the JWT MUST be identified by the value of the audience claim. 
        ''' If the principal processing the claim does not identify itself with the identifier in the aud claim value then the JWT MUST be rejected. 
        ''' The interpretation of the contents of the audience value is generally application specific. 
        ''' The aud value is case sensitive. This claim is OPTIONAL.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <DataMember(EmitDefaultvalue:=False, Order:=2)>
        Public Overridable Property aud As String = String.Empty

        ''' <summary>
        ''' The typ (type) claim is used to declare a type for the contents of this JWT. 
        ''' The typ value is case sensitive. 
        ''' This claim is OPTIONAL.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <DataMember(EmitDefaultvalue:=False, Order:=3)>
        Public Overridable Property typ As String = String.Empty

        ''' <summary>
        ''' The iat (issued at) claim identifies the UTC time at which the JWT was issued. 
        ''' The processing of the iat claim requires that the current date/time MUST be after the issued date/time listed in the iat claim. 
        ''' Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. 
        ''' This claim is OPTIONAL.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <DataMember(EmitDefaultvalue:=False, Order:=4)>
        Public Overridable Property iat As Integer

        ''' <summary>
        ''' The exp (expiration time) claim identifies the expiration time on or after which the token MUST NOT be accepted for processing. 
        ''' The processing of the exp claim requires that the current date/time MUST be before the expiration date/time listed in the exp claim. 
        ''' Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. 
        ''' This claim is OPTIONAL.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <DataMember(EmitDefaultvalue:=False, Order:=5)>
        Public Overridable Property exp As Integer?

        Public Sub New()
        End Sub

    End Class

End Namespace

